import java.util.*;

public class MovieManager {
    private List<Movie> movies = new ArrayList<>();

    public List<Movie> getMovies() {
        return movies;
    }

    public Movie findMovieByName(String name) {
        for (Movie m : movies) {
            if (m.getName().equals(name)) {
                return m;
            }
        }
        return null;
    }

    public boolean addMovie(Movie movie) {
        if (findMovieByName(movie.getName()) != null) return false;
        movies.add(movie);
        return true;
    }

    public boolean removeMovie(String name) {
        Iterator<Movie> it = movies.iterator();
        while (it.hasNext()) {
            if (it.next().getName().equals(name)) {
                it.remove();
                return true;
            }
        }
        return false;
    }
} 